package com.yiqi.zhiyuan.feature.certification.view.adapter;

import android.util.Log;
import android.view.View;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.yiqi.zhiyuan.R;
import com.yiqi.zhiyuan.entity.vo.BrandChildVO;
import com.yiqi.zhiyuan.entity.vo.BrandModelVO;

import java.util.List;

/**
 * @ProjectName: ZhiYuan
 * @Description: java类作用描述
 * @Author: lijuwen
 * @CreateDate: 2019/4/19 16:55
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/4/19 16:55
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class BrandAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {

    public static final int TYPE_LEVEL_BRAND = 0;
    public static final int TYPE_LEVEL_MODEL = 1;

    public BrandAdapter(List<MultiItemEntity> data) {
        super(data);
        addItemType(TYPE_LEVEL_BRAND, R.layout.item_popup_brand);
        addItemType(TYPE_LEVEL_MODEL, R.layout.item_popup_model);
    }

    @Override
    protected void convert(BaseViewHolder holder, MultiItemEntity item) {
        switch (holder.getItemViewType()) {
            case TYPE_LEVEL_BRAND:

                final BrandChildVO lv0 = (BrandChildVO) item;
                holder.setText(R.id.iv_brand_name, lv0.getSname())
                        .setImageResource(R.id.iv_brand_right, lv0.isExpanded() ? R.mipmap.ic_brand_up : R.mipmap.ic_brand_down);
//                holder.itemView.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        int pos = holder.getAdapterPosition();
//                        if (lv0.isExpanded()) {
//                            collapse(pos);
//                        } else {
//                            expand(pos);
//                        }
//                    }
//                });
                break;
            case TYPE_LEVEL_MODEL:
                final BrandModelVO lv1 = (BrandModelVO) item;
                holder.setText(R.id.iv_brand_model_name, lv1.getMname());
                break;
            default:
                break;

        }
    }

}
